<?php
class ReserveAction extends Action {
    
    //预定模块添加流程
    //用途：POST
    public function add(){
    	
    	$data["verifycode"] = $this->_post("verifycode");
    	if($data["verifycode"] != session("verifycode")){ 
		   echo CommonUtil::alertAndGoBack("验证码错误！");
		   return;
		}
    	
    	$catalogId = $this->_get("catalog_id");
		$catalog = CatalogHelper::getObject("catalog_id={$catalogId}");
		$reserveModule = ReserveModuleHelper::getObject("reserve_module_id={$catalog["dynamic_module_id"]}");
		$reserveModuleFieldList = ReserveModuleFieldHelper::getList("reserve_module_id={$catalog["dynamic_module_id"]}","order_num DESC");
    	
    	$sql = CommonUtil::getReserveModuleSaveOrUpdateSQL($this->_get(),$this->_post(), $reserveModule, $reserveModuleFieldList, "GetSaveSQL");
		$result = ReserveModuleHelper::updateSQL($sql);
    	if($result === false){
			echo CommonUtil::alertAndGoBack("服务器繁忙，请稍后重试！");
			return;
		}
		
		//执行成功
		$url = __APP__."/t/".$catalog["catalog_url_name"];
		
		header("Content-Type: text/html; charset=utf-8");
		echo '<script language="javascript">alert("操作成功，官方客服将尽快与您取得联系！");window.location.href="'.$url.'";</script>';
    	
    }
    
    
}